﻿using Newtonsoft.Json;

namespace SimpleTicketBooking.Models.Response
{
    public class ResponseResult<T>
    {
        public ResultStatus Code { get; set; }
        public string Message { get; set; } = string.Empty;
        public T? Data { get; set; }

        public static ResponseResult<T> Success(T data)
        {
            ResponseResult<T> result = new ResponseResult<T>();
            result.Code = ResultStatus.Success;
            result.Message = "Success";
            result.Data = data;
            return result;
        }

        public static ResponseResult<T> Failed(string errorMessage)
        {
            ResponseResult<T> result = new ResponseResult<T>();
            result.Code = ResultStatus.Error;
            result.Message = errorMessage;
            return result;
        }

        public string SerializeObject()
        {
            return JsonConvert.SerializeObject(this);
        }
    }
}
